package com.lin.operatorlogrecord.entity.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.lin.operatorlogrecord.exception.EnumException;
import lombok.Getter;

/**
 * @Author: chenghao.lin
 * @Date: 2023/09/21
 * @Description: 日志类型
 */
@Getter
public enum LogTypeEnum implements IEnumBase{

    USER_MANAGE(0, "用户管理日志"),
    USER_OPERATOR(1, "用户操作日志");

    @EnumValue
    @JsonValue
    private final Integer code;

    private final String name;

    LogTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public IEnumBase convertIEnumBase(Integer code) {
        for (LogTypeEnum logTypeEnum : LogTypeEnum.values()) {
            if (logTypeEnum.getCode().equals(code)) {
                return logTypeEnum;
            }
        }
        throw new EnumException("该整型值没有对应枚举：" + code);
    }
}
